package com.weijian.job.cycle;

import com.weijian.service.ArticleService;
import com.weijian.utils.SyncVectorUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 数据库文件同步到 ES向量数据库 的 Job
 */
//@Component
@Slf4j
@RequiredArgsConstructor
public class IncSyncPostToEs {


    final ArticleService articleService;

    final VectorStore vectorStore;

    /**
     * 每分钟执行一次
     */
    @Scheduled(fixedRate = 60 * 1000)
    public void run() {
        SyncVectorUtil.syncIfUpdated(articleService, vectorStore);
    }
}
